﻿using System;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace Auto_Buy
{
    public class HttpUnit
    {
        private static readonly HttpClient Client= new HttpClient();

        public static async Task<HttpResponseMessage> Post(object body)
        {
            return await Post("http://api.fangjinnet.com/api", body);
        }

        public static async Task<HttpResponseMessage> Post(string url, object body)
        {
            using (var content = new StringContent(JsonConvert.SerializeObject(body)))
            {
                return await Client.PostAsync(url, content);
            }
        }
    }
}
